import 'package:boss/models/offers.dart';

import 'package:boss/ui/page/offersManagement/page/offersDetail/provider/offers_detail_provider.dart';
import 'package:boss/ui/page/offersManagement/page/offersDetail/widget/offers_detail_browser.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';
import 'package:router/annotation.dart';

@RouterConfig(OffersDetailPage.pageName)
class OffersDetailPage extends StatefulWidget {
  static const pageName = '/offersDetailPage';

  @Autowired()
  final Offers data;

  @Autowired()
  final int type;

  const OffersDetailPage({
    Key key,
    this.data,
    this.type,
  }) : super(key: key);

  @override
  _OffersDetailPageState createState() => _OffersDetailPageState('优惠详情');
}

class _OffersDetailPageState extends BaseState<OffersDetailPage> {
  _OffersDetailPageState(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (context) => OffersDetailProvider(
            widget.data,
            widget.type,
          ),
        ),
      ],
      child: Scaffold(
        appBar: CenterTitleAppBar(
          title: '优惠详情',
        ),
        body: OffersDetailBrowser(),
      ),
    );
  }
}
